\(\int \frac {\sec ^2(x)}{(a+b \sin ^2(x))^2} \, dx\) [321]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 15, antiderivative size = 76 \[ \int \frac {\sec ^2(x)}{\left (a+b \sin ^2(x)\right )^2} \, dx=\frac {b (4 a+b) \arctan \left (\frac {\sqrt {a+b} \tan (x)}{\sqrt {a}}\right )}{2 a^{3/2} (a+b)^{5/2}}+\frac {\tan (x)}{(a+b)^2}+\frac {b^2 \tan (x)}{2 a (a+b)^2 \left (a+(a+b) \tan ^2(x)\right )} \]

[Out]

1/2*b*(4*a+b)*arctan((a+b)^(1/2)*tan(x)/a^(1/2))/a^(3/2)/(a+b)^(5/2)+tan(x)/(a+b)^2+1/2*b^2*tan(x)/a/(a+b)^2/(
a+(a+b)*tan(x)^2)

Rubi [A] (verified)

Time = 0.15 (sec) , antiderivative size = 76, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.267, Rules used = {3270, 398, 393, 211} \[ \int \frac {\sec ^2(x)}{\left (a+b \sin ^2(x)\right )^2} \, dx=\frac {b (4 a+b) \arctan \left (\frac {\sqrt {a+b} \tan (x)}{\sqrt {a}}\right )}{2 a^{3/2} (a+b)^{5/2}}+\frac {b^2 \tan (x)}{2 a (a+b)^2 \left ((a+b) \tan ^2(x)+a\right )}+\frac {\tan (x)}{(a+b)^2} \]

[In]

Int[Sec[x]^2/(a + b*Sin[x]^2)^2,x]

[Out]

(b*(4*a + b)*ArcTan[(Sqrt[a + b]*Tan[x])/Sqrt[a]])/(2*a^(3/2)*(a + b)^(5/2)) + Tan[x]/(a + b)^2 + (b^2*Tan[x])
/(2*a*(a + b)^2*(a + (a + b)*Tan[x]^2))

Rule 211

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(Rt[a/b, 2]/a)*ArcTan[x/Rt[a/b, 2]], x] /; FreeQ[{a, b}, x]
&& PosQ[a/b]

Rule 393

Int[((a_) + (b_.)*(x_)^(n_))^(p_)*((c_) + (d_.)*(x_)^(n_)), x_Symbol] :> Simp[(-(b*c - a*d))*x*((a + b*x^n)^(p
 + 1)/(a*b*n*(p + 1))), x] - Dist[(a*d - b*c*(n*(p + 1) + 1))/(a*b*n*(p + 1)), Int[(a + b*x^n)^(p + 1), x], x]
 /; FreeQ[{a, b, c, d, n, p}, x] && NeQ[b*c - a*d, 0] && (LtQ[p, -1] || ILtQ[1/n + p, 0])

Rule 398

Int[((a_) + (b_.)*(x_)^(n_))^(p_)*((c_) + (d_.)*(x_)^(n_))^(q_), x_Symbol] :> Int[PolynomialDivide[(a + b*x^n)
^p, (c + d*x^n)^(-q), x], x] /; FreeQ[{a, b, c, d}, x] && NeQ[b*c - a*d, 0] && IGtQ[n, 0] && IGtQ[p, 0] && ILt
Q[q, 0] && GeQ[p, -q]

Rule 3270

Int[cos[(e_.) + (f_.)*(x_)]^(m_)*((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)]^2)^(p_.), x_Symbol] :> With[{ff = FreeF
actors[Tan[e + f*x], x]}, Dist[ff/f, Subst[Int[(a + (a + b)*ff^2*x^2)^p/(1 + ff^2*x^2)^(m/2 + p + 1), x], x, T
an[e + f*x]/ff], x]] /; FreeQ[{a, b, e, f}, x] && IntegerQ[m/2] && IntegerQ[p]

Rubi steps \begin{align*} \text {integral}& = \text {Subst}\left (\int \frac {\left (1+x^2\right )^2}{\left (a+(a+b) x^2\right )^2} \, dx,x,\tan (x)\right ) \\ & = \text {Subst}\left (\int \left (\frac {1}{(a+b)^2}+\frac {b (2 a+b)+2 b (a+b) x^2}{(a+b)^2 \left (a+(a+b) x^2\right )^2}\right ) \, dx,x,\tan (x)\right ) \\ & = \frac {\tan (x)}{(a+b)^2}+\frac {\text {Subst}\left (\int \frac {b (2 a+b)+2 b (a+b) x^2}{\left (a+(a+b) x^2\right )^2} \, dx,x,\tan (x)\right )}{(a+b)^2} \\ & = \frac {\tan (x)}{(a+b)^2}+\frac {b^2 \tan (x)}{2 a (a+b)^2 \left (a+(a+b) \tan ^2(x)\right )}+\frac {(b (4 a+b)) \text {Subst}\left (\int \frac {1}{a+(a+b) x^2} \, dx,x,\tan (x)\right )}{2 a (a+b)^2} \\ & = \frac {b (4 a+b) \arctan \left (\frac {\sqrt {a+b} \tan (x)}{\sqrt {a}}\right )}{2 a^{3/2} (a+b)^{5/2}}+\frac {\tan (x)}{(a+b)^2}+\frac {b^2 \tan (x)}{2 a (a+b)^2 \left (a+(a+b) \tan ^2(x)\right )} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.55 (sec) , antiderivative size = 76, normalized size of antiderivative = 1.00 \[ \int \frac {\sec ^2(x)}{\left (a+b \sin ^2(x)\right )^2} \, dx=\frac {1}{2} \left (\frac {b (4 a+b) \arctan \left (\frac {\sqrt {a+b} \tan (x)}{\sqrt {a}}\right )}{a^{3/2} (a+b)^{5/2}}+\frac {\frac {b^2 \sin (2 x)}{a (2 a+b-b \cos (2 x))}+2 \tan (x)}{(a+b)^2}\right ) \]

[In]

Integrate[Sec[x]^2/(a + b*Sin[x]^2)^2,x]

[Out]

((b*(4*a + b)*ArcTan[(Sqrt[a + b]*Tan[x])/Sqrt[a]])/(a^(3/2)*(a + b)^(5/2)) + ((b^2*Sin[2*x])/(a*(2*a + b - b*
Cos[2*x])) + 2*Tan[x])/(a + b)^2)/2

Maple [A] (verified)

Time = 1.04 (sec) , antiderivative size = 81, normalized size of antiderivative = 1.07

method result size
default \(\frac {\tan \left (x \right )}{a^{2}+2 a b +b^{2}}+\frac {b \left (\frac {b \tan \left (x \right )}{2 a \left (a \left (\tan ^{2}\left (x \right )\right )+\left (\tan ^{2}\left (x \right )\right ) b +a \right )}+\frac {\left (4 a +b \right ) \arctan \left (\frac {\left (a +b \right ) \tan \left (x \right )}{\sqrt {a \left (a +b \right )}}\right )}{2 a \sqrt {a \left (a +b \right )}}\right )}{\left (a +b \right )^{2}}\) \(81\)
risch \(\frac {i \left (-4 a b \,{\mathrm e}^{4 i x}-b^{2} {\mathrm e}^{4 i x}+8 \,{\mathrm e}^{2 i x} a^{2}+2 a b \,{\mathrm e}^{2 i x}-2 a b +b^{2}\right )}{a \left (a +b \right )^{2} \left (-b \,{\mathrm e}^{4 i x}+4 a \,{\mathrm e}^{2 i x}+2 b \,{\mathrm e}^{2 i x}-b \right ) \left ({\mathrm e}^{2 i x}+1\right )}-\frac {b \ln \left ({\mathrm e}^{2 i x}-\frac {2 i a^{2}+2 i a b +2 a \sqrt {-a^{2}-a b}+b \sqrt {-a^{2}-a b}}{b \sqrt {-a^{2}-a b}}\right )}{\sqrt {-a^{2}-a b}\, \left (a +b \right )^{2}}-\frac {b^{2} \ln \left ({\mathrm e}^{2 i x}-\frac {2 i a^{2}+2 i a b +2 a \sqrt {-a^{2}-a b}+b \sqrt {-a^{2}-a b}}{b \sqrt {-a^{2}-a b}}\right )}{4 \sqrt {-a^{2}-a b}\, \left (a +b \right )^{2} a}+\frac {b \ln \left ({\mathrm e}^{2 i x}+\frac {2 i a^{2}+2 i a b -2 a \sqrt {-a^{2}-a b}-b \sqrt {-a^{2}-a b}}{b \sqrt {-a^{2}-a b}}\right )}{\sqrt {-a^{2}-a b}\, \left (a +b \right )^{2}}+\frac {b^{2} \ln \left ({\mathrm e}^{2 i x}+\frac {2 i a^{2}+2 i a b -2 a \sqrt {-a^{2}-a b}-b \sqrt {-a^{2}-a b}}{b \sqrt {-a^{2}-a b}}\right )}{4 \sqrt {-a^{2}-a b}\, \left (a +b \right )^{2} a}\) \(447\)

[In]

int(sec(x)^2/(a+b*sin(x)^2)^2,x,method=_RETURNVERBOSE)

[Out]

tan(x)/(a^2+2*a*b+b^2)+b/(a+b)^2*(1/2/a*b*tan(x)/(a*tan(x)^2+tan(x)^2*b+a)+1/2*(4*a+b)/a/(a*(a+b))^(1/2)*arcta
n((a+b)*tan(x)/(a*(a+b))^(1/2)))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 210 vs. \(2 (64) = 128\).

Time = 0.32 (sec) , antiderivative size = 505, normalized size of antiderivative = 6.64 \[ \int \frac {\sec ^2(x)}{\left (a+b \sin ^2(x)\right )^2} \, dx=\left [-\frac {{\left ({\left (4 \, a b^{2} + b^{3}\right )} \cos \left (x\right )^{3} - {\left (4 \, a^{2} b + 5 \, a b^{2} + b^{3}\right )} \cos \left (x\right )\right )} \sqrt {-a^{2} - a b} \log \left (\frac {{\left (8 \, a^{2} + 8 \, a b + b^{2}\right )} \cos \left (x\right )^{4} - 2 \, {\left (4 \, a^{2} + 5 \, a b + b^{2}\right )} \cos \left (x\right )^{2} + 4 \, {\left ({\left (2 \, a + b\right )} \cos \left (x\right )^{3} - {\left (a + b\right )} \cos \left (x\right )\right )} \sqrt {-a^{2} - a b} \sin \left (x\right ) + a^{2} + 2 \, a b + b^{2}}{b^{2} \cos \left (x\right )^{4} - 2 \, {\left (a b + b^{2}\right )} \cos \left (x\right )^{2} + a^{2} + 2 \, a b + b^{2}}\right ) + 4 \, {\left (2 \, a^{4} + 4 \, a^{3} b + 2 \, a^{2} b^{2} - {\left (2 \, a^{3} b + a^{2} b^{2} - a b^{3}\right )} \cos \left (x\right )^{2}\right )} \sin \left (x\right )}{8 \, {\left ({\left (a^{5} b + 3 \, a^{4} b^{2} + 3 \, a^{3} b^{3} + a^{2} b^{4}\right )} \cos \left (x\right )^{3} - {\left (a^{6} + 4 \, a^{5} b + 6 \, a^{4} b^{2} + 4 \, a^{3} b^{3} + a^{2} b^{4}\right )} \cos \left (x\right )\right )}}, -\frac {{\left ({\left (4 \, a b^{2} + b^{3}\right )} \cos \left (x\right )^{3} - {\left (4 \, a^{2} b + 5 \, a b^{2} + b^{3}\right )} \cos \left (x\right )\right )} \sqrt {a^{2} + a b} \arctan \left (\frac {{\left (2 \, a + b\right )} \cos \left (x\right )^{2} - a - b}{2 \, \sqrt {a^{2} + a b} \cos \left (x\right ) \sin \left (x\right )}\right ) + 2 \, {\left (2 \, a^{4} + 4 \, a^{3} b + 2 \, a^{2} b^{2} - {\left (2 \, a^{3} b + a^{2} b^{2} - a b^{3}\right )} \cos \left (x\right )^{2}\right )} \sin \left (x\right )}{4 \, {\left ({\left (a^{5} b + 3 \, a^{4} b^{2} + 3 \, a^{3} b^{3} + a^{2} b^{4}\right )} \cos \left (x\right )^{3} - {\left (a^{6} + 4 \, a^{5} b + 6 \, a^{4} b^{2} + 4 \, a^{3} b^{3} + a^{2} b^{4}\right )} \cos \left (x\right )\right )}}\right ] \]

[In]

integrate(sec(x)^2/(a+b*sin(x)^2)^2,x, algorithm="fricas")

[Out]

[-1/8*(((4*a*b^2 + b^3)*cos(x)^3 - (4*a^2*b + 5*a*b^2 + b^3)*cos(x))*sqrt(-a^2 - a*b)*log(((8*a^2 + 8*a*b + b^
2)*cos(x)^4 - 2*(4*a^2 + 5*a*b + b^2)*cos(x)^2 + 4*((2*a + b)*cos(x)^3 - (a + b)*cos(x))*sqrt(-a^2 - a*b)*sin(
x) + a^2 + 2*a*b + b^2)/(b^2*cos(x)^4 - 2*(a*b + b^2)*cos(x)^2 + a^2 + 2*a*b + b^2)) + 4*(2*a^4 + 4*a^3*b + 2*
a^2*b^2 - (2*a^3*b + a^2*b^2 - a*b^3)*cos(x)^2)*sin(x))/((a^5*b + 3*a^4*b^2 + 3*a^3*b^3 + a^2*b^4)*cos(x)^3 -
(a^6 + 4*a^5*b + 6*a^4*b^2 + 4*a^3*b^3 + a^2*b^4)*cos(x)), -1/4*(((4*a*b^2 + b^3)*cos(x)^3 - (4*a^2*b + 5*a*b^
2 + b^3)*cos(x))*sqrt(a^2 + a*b)*arctan(1/2*((2*a + b)*cos(x)^2 - a - b)/(sqrt(a^2 + a*b)*cos(x)*sin(x))) + 2*
(2*a^4 + 4*a^3*b + 2*a^2*b^2 - (2*a^3*b + a^2*b^2 - a*b^3)*cos(x)^2)*sin(x))/((a^5*b + 3*a^4*b^2 + 3*a^3*b^3 +
 a^2*b^4)*cos(x)^3 - (a^6 + 4*a^5*b + 6*a^4*b^2 + 4*a^3*b^3 + a^2*b^4)*cos(x))]

Sympy [F]

\[ \int \frac {\sec ^2(x)}{\left (a+b \sin ^2(x)\right )^2} \, dx=\int \frac {\sec ^{2}{\left (x \right )}}{\left (a + b \sin ^{2}{\left (x \right )}\right )^{2}}\, dx \]

[In]

integrate(sec(x)**2/(a+b*sin(x)**2)**2,x)

[Out]

Integral(sec(x)**2/(a + b*sin(x)**2)**2, x)

Maxima [A] (verification not implemented)

none

Time = 0.47 (sec) , antiderivative size = 119, normalized size of antiderivative = 1.57 \[ \int \frac {\sec ^2(x)}{\left (a+b \sin ^2(x)\right )^2} \, dx=\frac {b^{2} \tan \left (x\right )}{2 \, {\left (a^{4} + 2 \, a^{3} b + a^{2} b^{2} + {\left (a^{4} + 3 \, a^{3} b + 3 \, a^{2} b^{2} + a b^{3}\right )} \tan \left (x\right )^{2}\right )}} + \frac {{\left (4 \, a b + b^{2}\right )} \arctan \left (\frac {{\left (a + b\right )} \tan \left (x\right )}{\sqrt {{\left (a + b\right )} a}}\right )}{2 \, {\left (a^{3} + 2 \, a^{2} b + a b^{2}\right )} \sqrt {{\left (a + b\right )} a}} + \frac {\tan \left (x\right )}{a^{2} + 2 \, a b + b^{2}} \]

[In]

integrate(sec(x)^2/(a+b*sin(x)^2)^2,x, algorithm="maxima")

[Out]

1/2*b^2*tan(x)/(a^4 + 2*a^3*b + a^2*b^2 + (a^4 + 3*a^3*b + 3*a^2*b^2 + a*b^3)*tan(x)^2) + 1/2*(4*a*b + b^2)*ar
ctan((a + b)*tan(x)/sqrt((a + b)*a))/((a^3 + 2*a^2*b + a*b^2)*sqrt((a + b)*a)) + tan(x)/(a^2 + 2*a*b + b^2)

Giac [A] (verification not implemented)

none

Time = 0.32 (sec) , antiderivative size = 113, normalized size of antiderivative = 1.49 \[ \int \frac {\sec ^2(x)}{\left (a+b \sin ^2(x)\right )^2} \, dx=\frac {b^{2} \tan \left (x\right )}{2 \, {\left (a^{3} + 2 \, a^{2} b + a b^{2}\right )} {\left (a \tan \left (x\right )^{2} + b \tan \left (x\right )^{2} + a\right )}} + \frac {{\left (4 \, a b + b^{2}\right )} \arctan \left (\frac {a \tan \left (x\right ) + b \tan \left (x\right )}{\sqrt {a^{2} + a b}}\right )}{2 \, {\left (a^{3} + 2 \, a^{2} b + a b^{2}\right )} \sqrt {a^{2} + a b}} + \frac {\tan \left (x\right )}{a^{2} + 2 \, a b + b^{2}} \]

[In]

integrate(sec(x)^2/(a+b*sin(x)^2)^2,x, algorithm="giac")

[Out]

1/2*b^2*tan(x)/((a^3 + 2*a^2*b + a*b^2)*(a*tan(x)^2 + b*tan(x)^2 + a)) + 1/2*(4*a*b + b^2)*arctan((a*tan(x) +
b*tan(x))/sqrt(a^2 + a*b))/((a^3 + 2*a^2*b + a*b^2)*sqrt(a^2 + a*b)) + tan(x)/(a^2 + 2*a*b + b^2)

Mupad [B] (verification not implemented)

Time = 13.91 (sec) , antiderivative size = 123, normalized size of antiderivative = 1.62 \[ \int \frac {\sec ^2(x)}{\left (a+b \sin ^2(x)\right )^2} \, dx=\frac {\mathrm {tan}\left (x\right )}{{\left (a+b\right )}^2}+\frac {b^2\,\mathrm {tan}\left (x\right )}{2\,a\,\left (a\,b^2+2\,a^2\,b+{\mathrm {tan}\left (x\right )}^2\,\left (a^3+3\,a^2\,b+3\,a\,b^2+b^3\right )+a^3\right )}+\frac {b\,\mathrm {atan}\left (\frac {b\,\mathrm {tan}\left (x\right )\,\left (4\,a+b\right )\,\left (2\,a+2\,b\right )\,\left (a^2+2\,a\,b+b^2\right )}{2\,\sqrt {a}\,{\left (a+b\right )}^{5/2}\,\left (b^2+4\,a\,b\right )}\right )\,\left (4\,a+b\right )}{2\,a^{3/2}\,{\left (a+b\right )}^{5/2}} \]

[In]

int(1/(cos(x)^2*(a + b*sin(x)^2)^2),x)

[Out]

tan(x)/(a + b)^2 + (b^2*tan(x))/(2*a*(a*b^2 + 2*a^2*b + tan(x)^2*(3*a*b^2 + 3*a^2*b + a^3 + b^3) + a^3)) + (b*
atan((b*tan(x)*(4*a + b)*(2*a + 2*b)*(2*a*b + a^2 + b^2))/(2*a^(1/2)*(a + b)^(5/2)*(4*a*b + b^2)))*(4*a + b))/
(2*a^(3/2)*(a + b)^(5/2))